import { reqCategoryData } from '../../api/category'

Page({
  //初始化数据
  data: {
    categoryList: [], //商品分类列表
    activeIndex: 0
  },
  async getCategoryData() {
    const res = await reqCategoryData()
    if (res.code == 200) {
      this.setData({
        categoryList: res.data
      })
    }
  },
  updateActive(e) {
    this.setData({
      activeIndex: e.currentTarget.dataset.index
    })
  },
  //监听页面加载
  onLoad() {
    this.getCategoryData()
  }
})
